var express = require('express');

var app = express();

// var fs = require('fs')

app.get('/listUser', (req, res) => {
    res.header('content-type', 'application/json;charset=utf-8')
    let data = '{"userId":11, "name":"哈哈哈"}'
    res.end(data)
})

app.get('/:id', (request, response) => {
    response.header('content-type', 'application/json;charset=utf-8')
    let data = '{"userId":'+request.params.id+', "name":"哈哈哈"}'
    response.end(data)
})

//post、delete、put方法类似

var server = app.listen(8081, () => {
    let host = server.address().address
    let port = server.address().port
    console.log("应用实例，访问地址为 http://%s:%s", host, port)
})